<template>
  <view>
    <!-- 商品列表 -->
    <view class="goodsList">
      <!-- 单个商品块 -->
      <block v-for="(item,i) in goodsList" :key="i">
        <my-goods :goods="item"></my-goods>
      </block>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        queryObj:{
          query:"",
          cid:"",
          pageNum:"",
          pageSize:10
        },
        total:0,
        goodsList:[]
      };
    },
    onLoad(opt) {
      this.queryObj.query = opt.query || ''
      this.queryObj.cid = opt.cid || ''
      // 获取商品列表
      this.getSearchList()
    },
    methods:{
      async getSearchList(){
        const {data:res} = await uni.$http.get('/api/public/v1/goods/search',this.queryObj)
        if(res.meta.status !== 200){
          return uni.$showMsg()
        }
        this.goodsList = res.message.goods
        this.total = res.message.total
      }
    }
  }
</script>

<style lang="scss">

</style>
